import 'dart:async';
import 'dart:core';
import 'dart:developer';

import 'package:FlutterDemo/common/commons.dart';
import 'package:FlutterDemo/providers/page_providers_list.dart';
import 'package:FlutterDemo/widget/anims/page_anims.dart';
import 'package:FlutterDemo/widget/basicused/page_basic_useds.dart';
import 'package:FlutterDemo/widget/communications/page_channel_basicmsg.dart';
import 'package:FlutterDemo/widget/communications/page_channel_event.dart';
import 'package:FlutterDemo/widget/communications/page_channel_method.dart';
import 'package:FlutterDemo/widget/customerviews/page_customerviews.dart';
import 'package:FlutterDemo/widget/customerviews/page_sample_appbar.dart';
import 'package:FlutterDemo/widget/customerviews/page_sample_bottomnavigationbar.dart';
import 'package:FlutterDemo/widget/customerviews/page_sample_drawer.dart';
import 'package:FlutterDemo/widget/customerviews/page_sample_material.dart';
import 'package:FlutterDemo/widget/customerviews/page_sample_scaffold.dart';
import 'package:FlutterDemo/widget/customerviews/page_sample_snackbar.dart';
import 'package:FlutterDemo/widget/gesturedetector/page_gesturedetector.dart';
import 'package:FlutterDemo/widget/layout/page_customer_layouts.dart';
import 'package:FlutterDemo/widget/layout/page_flow.dart';
import 'package:FlutterDemo/widget/layout/page_layouts.dart';
import 'package:FlutterDemo/widget/layout/page_row_and_column.dart';
import 'package:FlutterDemo/widget/layout/page_row_crossaligment.dart';
import 'package:FlutterDemo/widget/layout/page_sampe_juejing.dart';
import 'package:FlutterDemo/widget/layout/page_sample_circle_flod.dart';
import 'package:FlutterDemo/widget/layout/page_sample_horizontal_flod.dart';
import 'package:FlutterDemo/widget/layout/page_stack.dart';
import 'package:FlutterDemo/widget/plugin/page_plugin1_parctical.dart';
import 'package:FlutterDemo/widget/plugin/page_plugin2_parctical.dart';
import 'package:FlutterDemo/widget/plugin/page_plugin3_parctical.dart';
import 'package:FlutterDemo/widget/plugin/page_plugin4_parctical.dart';
import 'package:FlutterDemo/widget/plugin/page_plugin5_parctical.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/page_sample_bloc1.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/page_sample_bloc2.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/page_sample_bloc3.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/page_sample_bloc4.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/page_sample_bloc5.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/practice/page_bloc_practice1.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/practice/page_bloc_practice2.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/practice/page_bloc_practice3.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/practice/page_bloc_practice4.dart';
import 'package:FlutterDemo/widget/practicalextension/bloc/practice/page_bloc_practice5.dart';
import 'package:FlutterDemo/widget/practicalextension/flutterbloc/sample_flutterbloc1.dart';
import 'package:FlutterDemo/widget/practicalextension/flutterbloc/sample_flutterbloc2.dart';
import 'package:FlutterDemo/widget/practicalextension/flutterbloc/sample_flutterbloc3.dart';
import 'package:FlutterDemo/widget/practicalextension/flutterbloc/sample_flutterbloc4.dart';
import 'package:FlutterDemo/widget/practicalextension/flutterbloc/sample_flutterbloc5.dart';
import 'package:FlutterDemo/widget/practicalextension/getx/sample_getx1.dart';
import 'package:FlutterDemo/widget/practicalextension/getx/sample_getx2.dart';
import 'package:FlutterDemo/widget/practicalextension/provider/page_sample_provider1.dart';
import 'package:FlutterDemo/widget/practicalextension/provider/page_sample_provider2.dart';
import 'package:FlutterDemo/widget/practicalextension/provider/page_sample_provider3.dart';
import 'package:FlutterDemo/widget/practicalextension/provider/page_sample_provider4.dart';
import 'package:FlutterDemo/widget/practicalextension/provider/page_sample_provider5.dart';
import 'package:FlutterDemo/widget/practicalextension/rxdart/sample_rxdart1.dart';
import 'package:FlutterDemo/widget/practicalextension/rxdart/sample_rxdart2.dart';
import 'package:FlutterDemo/widget/routers/page_routers.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_horizontal_listview.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_horizontal_listview_banner.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_horizontal_listview_scroll.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_listview.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_listview_builder.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_listview_scroll2pos.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_listview_scrollcontroller.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/listview/page_sub_sample_listview_separated.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/scrollbars/page_sub_sample_myscrollbars.dart';
import 'package:FlutterDemo/widget/scrollviews/helpers/scrollbars/page_sub_sample_scrollbars.dart';
import 'package:FlutterDemo/widget/scrollviews/page_customerpageview.dart';
import 'package:FlutterDemo/widget/scrollviews/page_datatable.dart';
import 'package:FlutterDemo/widget/scrollviews/page_gridview.dart';
import 'package:FlutterDemo/widget/scrollviews/page_pageview.dart';
import 'package:FlutterDemo/widget/scrollviews/page_singlechild_scrollview.dart';
import 'package:FlutterDemo/widget/sliver/page_custom_scrollview.dart';
import 'package:FlutterDemo/widget/sliver/page_nestedscrollview.dart';
import 'package:FlutterDemo/widget/sliver/page_sliver_persistentheader.dart';
import 'package:FlutterDemo/widget/sliver/page_sliver_topboxadapter.dart';
import 'package:FlutterDemo/widget/sliver/page_sliverappbar.dart';
import 'package:FlutterDemo/widget/sliver/page_slivergrid.dart';
import 'package:FlutterDemo/widget/sliver/page_sliverlist.dart';
import 'package:FlutterDemo/widget/texts/page_texts.dart';
import 'package:FlutterDemo/widget/vrp/page_vrps.dart';
import 'package:FlutterDemo/widget/weight/page_aspectratio.dart';
import 'package:FlutterDemo/widget/weight/page_chart.dart';
import 'package:FlutterDemo/widget/weight/page_container.dart';
import 'package:FlutterDemo/widget/weight/page_efs.dart';
import 'package:FlutterDemo/widget/weight/page_fsizebox.dart';
import 'package:FlutterDemo/widget/weight/page_sample_ju_me_header.dart';
import 'package:FlutterDemo/widget/weight/page_sizebox.dart';
import 'package:FlutterDemo/widget/weight/page_weight.dart';
import 'package:flutter/material.dart';

import 'datas.dart';

/// 创建数据工厂
class BeansFactory {
  BeansFactory.privateConsturctor();

  // 创建构造
  static final BeansFactory instance = BeansFactory.privateConsturctor();

  /// 构建首页数据
  List<PageInfo> newBuildMainPager() {
    var list = <PageInfo>[];
    var provider = buildSampleListPageProvider();
    var pageos = provider.buildListPageWidget(ListPageTarget.PAGEROSAPPWIDGET);
    var pagesliver = provider.buildListPageWidget(ListPageTarget.PAGERSLIVERVIEWSAPPWIDGET);
    var pagesscrollview = provider.buildListPageWidget(ListPageTarget.PAGERSCROLLVIEWSAPPWIDGET);
    var pagespracticalview = provider.buildListPageWidget(ListPageTarget.PRACTICALEXTENSIONAPPWIDGET);
    var pageCommuncation = provider.buildListPageWidget(ListPageTarget.PAGEANDROIDFLUTTERCOMMUNCATION);
    // 使用映射关系创建界面
    var map = Map.of({
      "文本组件": PageTextAppWidget(),
      "基础组件": PageBasicUsedAppWidget(),
      "布局组件": PageLayoutAppWidget(),
      "定位装饰权重组件": PageWeightAppWidget(),
      "手势识别组件": PagerGestureDetectorAppwidget(),
      "滚动和大数据组件": pagesscrollview,
      "Sliver系列组件": pagesliver,
      "功能型组件": PagerCustomerViewsAppwidget(),
      "App级别组件": pageos,
      "动画": PagerAnimationswidget(),
      "路由": PagerRoutesidget(),
      "数据存储和网络请求": PagerVirtualResourcePoolAppwidget(),
      "混合开发": pageCommuncation,
      "扩展实践": pagespracticalview,
    });

    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// 异步加载
  List<PageInfo> buildMainPagerList() {
    log("返回数据");
    return newBuildMainPager();
  }

  /// 异步加载
  Future<List<PageInfo>> buildMainPagerAsync() async {
    log("模拟 数据获取");
    await new Future.delayed(const Duration(milliseconds: 300)); // 当前线程休眠5s
    log("返回数据");
    return newBuildMainPager();
  }

  /// 构建自定义view二级子界面
  List<PageInfo> buildCustomerViewPageMainList() {
    log("构建数据");
    var map = Map.of({
      "MaterialApp": SampleMaterialAppWidget(),
      "脚手架-Scaffold": SampleScaffoldWidget(),
      "导航栏-Appbar": SampleAppbarWidget(),
      "抽屉布局-Drawer": SampleDrawerWidget(),
      "底部切换布局-BottomNavigationBar": SampleBottomNavigationBarWidget(),
      "消息提示-SnackBar": SampleSnackBarWidget()
    });

    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, element.value));
    });
    return list;
  }

  /// 构建自定义view二级子界面
  Future<List<PageInfo>> buildCustomerViewPageMainListAsync() async {
    log("构建数据");
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildCustomerViewPageMainList();
  }

  /// listview&大数据
  List<PageInfo> buildScrollPageDatas() {
    var provider = buildSampleListPageProvider();
    var listpage = provider.buildListPageWidget(ListPageTarget.PAGELISTVIEWWIDGET);
    var scrollbar = provider.buildListPageWidget(ListPageTarget.PAGESCROLLBARSWIDGET);

    log("构建数据");
    var map = Map.of({
      "List": listpage,
      "GridView": SampleGridViewWidget(),
      "SingleChildScrollView": SampleSingleChildScrollViewWidget(),
      "PageView": SamplePageViewWidget(),
      "DataTable": SampleDataTableWidget(),
      "自定义PageView切换动画": SampleMatrixTransformPageViewWidget(),
      "滚动条": scrollbar
    });

    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// listview&大数据
  Future<List<PageInfo>> buildScrollPageDatasAsync() async {
    log("构建数据");
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildScrollPageDatas();
  }

  /// 构建布局组件列表
  List<PageInfo> buildLayoutsDataList() {
    var map = Map.of({
      "水平&垂直布局": PageRCWidget(),
      "水平交叉轴": PageRowCrossAligmentWidget(),
      "叠加布局": PageStackWidget(),
      "流式布局": PageFlowWidget(),
      "自定义布局": PageCustomerWidget(),
      "仿 掘金-我的界面": PageJuejingWidget(),
      "水平展开/收起菜单": PageHorizontalFlodWidget(),
      "半圆展开/收起菜单": PageCircleFlodWidget()
    });

    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  Future<List<PageInfo>> buildLayoutsDataListAsync() async {
    var list = await buildLayoutsDataList();
    return list;
  }

  /// 构建测试列表
  Future<List<ItemWrapper>> buildScrollControllerListData() async {
    await Future.delayed(const Duration(milliseconds: 300));
    List<ItemWrapper> list = [];
    list.add(ItemWrapper('詹姆斯'));
    list.add(ItemWrapper('杜兰特'));
    list.add(ItemWrapper('库里'));
    list.add(ItemWrapper('哈登'));
    list.add(ItemWrapper('威少'));
    list.add(ItemWrapper('欧文'));
    list.add(ItemWrapper('戴维斯'));
    list.add(ItemWrapper('汤神'));
    list.add(ItemWrapper('格林'));
    list.add(ItemWrapper('恩比德'));
    list.add(ItemWrapper('保罗'));
    list.add(ItemWrapper('乔丹'));
    list.add(ItemWrapper('莱昂纳德'));
    list.add(ItemWrapper('塔图姆'));
    list.add(ItemWrapper('利拉德'));
    list.add(ItemWrapper('乐福'));
    list.add(ItemWrapper('科比'));
    return list;
  }

  /// 构建GridView列表
  Future<List<Widget>> buildSampleGridViewItems() async {
    await Future.delayed(const Duration(milliseconds: 300));
    List<Widget> views = [];
    for (var c in Colors.primaries) {
      views.add(_createGridViewItem(c));
    }
    return views;
  }

  _createGridViewItem(Color color) {
    return Container(
      height: 80,
      color: color,
    );
  }

  /// 构建测试用的url
  buildSampleListUrls() {
    return buildSampleGankioGirList();
  }

  /// 构建 gank.io妹子图片列表
  /// 来源：https://gank.io/api/v2/data/category/Girl/type/Girl/page/2/count/20
  buildSampleGankioGirList() {
    List<String> imgList = <String>[];
    imgList.add("https://gank.io/images/f4f6d68bf30147e1bdd4ddbc6ad7c2a2");
    imgList.add("https://gank.io/images/882afc997ad84f8ab2a313f6ce0f3522");
    imgList.add("https://gank.io/images/02eb8ca3297f4931ab64b7ebd7b5b89c");
    imgList.add("https://gank.io/images/b140f015a16e444aad6d76262f676a78");
    imgList.add("https://gank.io/images/b0f73f9527694f44b523ff059d8a8841");
    imgList.add("http://gank.io/images/f4f6d68bf30147e1bdd4ddbc6ad7c2a2");
    imgList.add("http://gank.io/images/dc75cbde1d98448183e2f9514b4d1320");
    imgList.add("http://gank.io/images/6b2efa591564475fb8bc32291fb0007c");
    imgList.add("http://gank.io/images/d6bba8cf5b8c40f9ad229844475e9149");
    imgList.add("http://gank.io/images/9fa43020cf724c69842eec3e13f6d21c");
    imgList.add("http://gank.io/images/d237f507bf1946d2b0976e581f8aab9b");
    imgList.add("http://gank.io/images/25d3e3db2c1248bb917c09dc4f50a46f");
    imgList.add("http://gank.io/images/19c99c447e0a40a6b3ff89951957cfb1");
    imgList.add("http://gank.io/images/f0c192e3e335400db8a709a07a891b2e");
    imgList.add("http://gank.io/images/bdb35e4b3c0045c799cc7a494a3db3e0");
    imgList.add("http://gank.io/images/95ddb01b6bd34a85aedfda4c9e9bd003");
    imgList.add("http://gank.io/images/5fe5b1e9168d4a8a8f6f4e0acefef8f5");
    imgList.add("http://gank.io/images/f7b320f1a89a4aaebadb1922c2a7a368");
    imgList.add("http://gank.io/images/80d2906331444e658aa876f5d4355f70");
    imgList.add("http://gank.io/images/d5c0dc1618194a65b928c932dd2de3a7");
    imgList.add("http://gank.io/images/291ee91a554f4cd88bf9a09a9fa2e95e");
    imgList.add("http://gank.io/images/b25e97747ed041fbb7a11f59f7fed5da");
    imgList.add("http://gank.io/images/31f485fdc49047f6883f52b73ac102aa");
    imgList.add("http://gank.io/images/4817628a6762410895f814079a6690a1");
    imgList.add("http://gank.io/images/0f536c69ada247429b8a9e38d3dba8bb");
    imgList.add("http://gank.io/images/5cc0fd124d2443448b6156284720707c");
    imgList.add("http://gank.io/images/1a515f1508e345e2bf24673c2c2d50c4");
    imgList.add("http://gank.io/images/f9523ebe24a34edfaedf2dd0df8e2b99");
    imgList.add("http://gank.io/images/2c924db2a1b84c5d8fdb9f8c5f6d1b71");
    imgList.add("http://gank.io/images/4002b1fd18544802b80193fad27eaa62");
    imgList.add("http://gank.io/images/5a29ab0fc093408c82febe7c7e42e156");
    imgList.add("http://gank.io/images/a2d3115b8d464d93933e79e88af03580");
    imgList.add("http://gank.io/images/fae111696a8b418297833324ff93bd1a");
    imgList.add("http://gank.io/images/c6d3b2b6b5e24e1cbf576946dbec5907");
    imgList.add("http://gank.io/images/e941fa5d2cfb4a8297128178c371908c");
    return imgList;
  }

  /// 构建listview子界面
  List<PageInfo> buildSampleSubList() {
    var map = Map.of({
      "简单列表": SubSampleListViewWidget(),
      "简单列表 Builder": SubSampleListViewBuilderWidget(),
      "动态创建数据": SubSampleHorizontalListViewWidget(),
      "分割线": SubSampleListViewSeparatedWidget(),
      "横向滚动": SubSampleHorizontalListViewScrollWidget(),
      "横向图片列表": SubSampleHorizontalListViewBannerWidget(),
      "滚动控制器示例": SubSampleListViewScrollControllerWidget(),
      "滚动到指定位置": SubSampleListViewScroll2posWidget()
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// 构建listview子界面
  Future<List<PageInfo>> buildSampleSubListAsync() async {
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildSampleSubList();
  }

  /// 构建Scrollbars子界面
  List<PageInfo> buildSampleScrollbarsList() {
    var map = Map.of({
      "标准Scrollbar": SampleScrollbarWidget(),
      "自定义Scrollbar": SampleMyScrollbarWidget(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// 构建Scrollbars子界面
  Future<List<PageInfo>> buildSampleScrollbarsListAsync() async {
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildSampleScrollbarsList();
  }

  /// 构建Sliver子界面
  List<PageInfo> buildSampleSlivers() {
    var map = Map.of({
      "SliverLst": SampleSliverListWidget(),
      "SliverGrid": SampleSliverGridWidget(),
      "SliverAppbar": SampleSliverAppbarWidget(),
      "SliverPersistentHeader": SampleSliverPersistentHeaderWidget(),
      "SliverTopBoxAdapter": SampleSliverTopBoxAdapterWidget(),
      "SliverCustomScrollView": SampleSliverCustomScrollviewWidget(),
      "SliverNestedScrollView": SampleSliverNestedScrollviewWidget(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// 构建Sliver子界面
  Future<List<PageInfo>> buildSampleSliversAsync() async {
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildSampleSlivers();
  }

  /// 构建状态管理子界面
  List<PageInfo> buildSamplePracticalExtensionList() {
    var provider = buildSampleListPageProvider();
    var liststatemanager = provider.buildListPageWidget(ListPageTarget.PAGEAPPSTATEMANAGERSWIDGET);
    var pluginlist = provider.buildListPageWidget(ListPageTarget.PAGEPLUGINLIST);

    var map = Map.of({
      "状态管理": liststatemanager,
      "插件": pluginlist,
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  SampleListPageProvider buildSampleListPageProvider() => new SampleListPageProvider();

  /// 构建状态管理子界面
  Future<List<PageInfo>> buildSamplePracticalExtensionListAsync() async {
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildSamplePracticalExtensionList();
  }

  /// 构建状态管理子界面
  List<PageInfo> buildSampleStateManagersList() {
    var provider = buildSampleListPageProvider();
    var listprovider = provider.buildListPageWidget(ListPageTarget.PAGEPROVIDERLISTWIDGET);
    var listbloc = provider.buildListPageWidget(ListPageTarget.PAGEBLOCLISTWIDGET);
    var flutterBloc = provider.buildListPageWidget(ListPageTarget.FLUTTERBLOC);
    var getxs = provider.buildListPageWidget(ListPageTarget.GETX);
    var rxdart = provider.buildListPageWidget(ListPageTarget.RXDART);

    var map = Map.of({
      "Provider": listprovider,
      "Bloc": listbloc,
      "RxDart": rxdart,
      "FlutterBloc": flutterBloc,
      "GetX": getxs,
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// 构建状态管理子界面
  Future<List<PageInfo>> buildSampleStateManagersListAsync() async {
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildSampleStateManagersList();
  }

  /// 构建Providers管理子界面
  List<PageInfo> buildSampleProviders() {
    var map = Map.of({
      "Provider-1": SampleProvider1Widget(),
      "Provider-2": SampleProvider2Widget(),
      "Provider-3": SampleProvider3Widget(),
      "Provider-4": SampleProvider4Widget(),
      "Provider-5": SampleProvider5Widget(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// 构建Providers管理子界面
  Future<List<PageInfo>> buildSampleProvidersAsync() async {
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildSampleProviders();
  }

  /// 构建Blocs管理子界面
  List<PageInfo> buildSampleBlocs() {
    var provider = buildSampleListPageProvider();
    var pageblocpractical = provider.buildListPageWidget(ListPageTarget.PAGEBLOCPRACTICALWIDGET);
    var map = Map.of({
      "Bloc-1": SampleBloc1Widget(),
      "Bloc-2": SampleBloc2Widget(),
      "Bloc-3": SampleBloc3Widget(),
      "Bloc-4": SampleBloc4Widget(),
      "Bloc-5": SampleBloc5Widget(),
      "Bloc实践": pageblocpractical,
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  /// 构建Blocs管理子界面
  Future<List<PageInfo>> buildSampleBlocsAsync() async {
    await new Future.delayed(const Duration(milliseconds: 300));
    return buildSampleBlocs();
  }

  buildBlocPracticalList() {
    var map = Map.of({
      "Bloc实践-1": SampleBlocPractical1Widget(),
      "Bloc实践-2": SampleBlocPractical2Widget(),
      "Bloc实践-3": SampleBlocPractical3Widget(),
      "Bloc实践-4": SampleBlocPractica4Widget(),
      "Bloc实践-5": SampleBlocPractical5Widget()
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  buildPluginPracticalList() {
    var map = Map.of({
      "Plugin实践-1": Plugin1ParticalWidget(),
      "Plugin实践-2": Plugin2ParticalWidget(),
      "Plugin实践-3": Plugin3ParticalWidget(),
      "Plugin实践-4": Plugin4ParticalWidget(),
      "Plugin实践-5": Plugin5ParticalWidget()
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, element.value));
    });
    return list;
  }

  /// 通信子项目
  buildCommuncList() {
    var map = Map.of({
      "MethodChannel": PageMethodChannel(),
      "EventChannel": PageEventChannel(),
      "BasicMethodChannel": PageBasicMsgChannel(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  List<PageInfo> builLocationWrapperWidgetList() {
    var map = Map.of({
      "Plugin实践-1": PageContainer(),
      "Plugin实践-2": PageSizeBox(),
      "Plugin实践-3": PageAspectration(),
      "Plugin实践-4": PageFySizeBox(),
      "Plugin实践-5": PageEFS(),
      "Plugin实践-6": PageJueJMeHeader(),
      "Plugin实践-7": PageChart(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  List<PageInfo> builFlutterBlocWidgetList() {
    var map = Map.of({
      "FlutterBloc-1": SampleFlutterBloc1(),
      "FlutterBloc-2": SampleFlutterBloc2(),
      "FlutterBloc-3": SampleFlutterBloc3(),
      "FlutterBloc-4": SampleFlutterBloc4(),
      "FlutterBloc-5": SampleFlutterBloc5(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      // list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
      list.add(PageInfo(element.key, element.value));
    });
    return list;
  }

  List<PageInfo> builGetXList() {
    var map = Map.of({
      "GetX-1": SampleGetX1(),
      "GetX-2": SampleGetX2(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }

  List<PageInfo> builRxDartList() {
    var map = Map.of({
      "RxDart-1": SampleRxDart1(),
      "RxDart-2": SampleRxDart2(),
    });
    var list = <PageInfo>[];
    map.entries.forEach((element) {
      list.add(PageInfo(element.key, buildBasicMaterialAppWidget(element.key, element.value)));
    });
    return list;
  }
}

/// 简易数据提供工厂: 使用工厂构造函数实现的单例
class SampleBeanFactory {
  static final SampleBeanFactory _instance = SampleBeanFactory.internal();

  // 私有化构造函数
  SampleBeanFactory.internal();

  factory SampleBeanFactory() => _instance;
}

// 条目包装
class ItemWrapper {
  final String displayName;
  bool selected;

  // 可选构造，参数必须默认初始化
  ItemWrapper(this.displayName, {this.selected = false});
}
